package com.example.provider.service.Impl;

import java.util.List;

import com.example.common.model.SquareArticleFavorite;
import com.example.common.model.condition.SquareArticleFavoriteCondition;
import com.example.provider.mapper.SquareArticleFavoriteMapper;
import com.example.provider.service.SquareArticleFavoriteService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * 广场文章用户喜欢关系表Service接口实现
 *
 * @author 510
 * @version 1.0.0 2021-04-23
 */
@Service
@Transactional(readOnly = true)
public class SquareArticleFavoriteServiceImpl extends ServiceImpl<SquareArticleFavoriteMapper, SquareArticleFavorite> implements SquareArticleFavoriteService {
    private static final Logger logger = LoggerFactory.getLogger(SquareArticleFavoriteService.class);

    @Override
    public IPage<SquareArticleFavorite> findSquareArticleFavoriteByCondition(SquareArticleFavoriteCondition condition) {
        IPage<SquareArticleFavorite> page = condition.buildPage();
        QueryWrapper<SquareArticleFavorite> queryWrapper = condition.buildQueryWrapper(SquareArticleFavorite.class);
        return this.page(page, queryWrapper);
    }

    @Override
    public SquareArticleFavorite getSquareArticleFavoriteById(Integer id) {
        return this.getById(id);
    }

    @Transactional
    @Override
    public boolean addSquareArticleFavorite(SquareArticleFavorite squareArticleFavorite) {
        return this.save(squareArticleFavorite);
    }

    @Transactional
    @Override
    public boolean updateSquareArticleFavorite(SquareArticleFavorite squareArticleFavorite) {
        return this.updateById(squareArticleFavorite);
    }

    @Transactional
    @Override
    public boolean deleteSquareArticleFavoriteById(Integer id) {
        return this.removeById(id);
    }

    @Transactional
    @Override
    public boolean deleteSquareArticleFavoriteByIds(List<Integer> idList) {
        return this.removeByIds(idList);
    }
}